<template>
    <div>
<h1>登录</h1>
<table class="table">
    <tbody>
        <tr>
            <td>用户名</td>
            <td><input type="text" v-model="da.name"></td>
        </tr>

        <tr>
            <td>密码</td>
            <td><input type="password" v-model="da.pwd"></td>
        </tr>

        <tr>
            <td></td>
            <td><input type="button" value="登录" @click="dl"></td>
        </tr>
    </tbody>
</table>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { ref } from 'vue';
import { useRouter } from 'vue-router';
import { usebbbStore } from '@/stores/sb';
const sb=usebbbStore()
const router=useRouter()
const da=ref({
  "name": "",
  "pwd": "",
})

const dl=()=>{
    axios.get("https://localhost:7127/api/Hy/Login",{params:da.value}).then(res=>{
        if(res.data.hyId==-1){
            alert("账号不存在")
        }
        if(res.data.hyId==-2){
            alert("密码错误")
        }
        if(res.data.hyId>0){
            alert("登录成功")
          sb.data.name=res.data.hyName
            router.push({path:'/addhy'})
        }
    })
}
</script>

<style scoped>

</style>